<template>
  <div style="display: flex;flex-direction: column;width: 100%">
    <Header :activeName="activeName"></Header>
    <div style="display: flex;margin-top: 90px;height: 30px;line-height: 30px;justify-content: center;">
      <el-breadcrumb :separator-icon="ArrowRight" style="height: 30px;width: 80%;align-items: center;line-height: 30px">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{path: '/news'}">新闻资讯</el-breadcrumb-item>
        <el-breadcrumb-item>新闻资讯</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <main class="main">
      <div class="news-d-container">
        <div class="news-d-title">{{newsDetail.title}}</div>
        <p class="news-d-info">
          <span style="margin-left: 10px">
            作者：admin
          </span>
          <span style="margin-left: 30px">
            发布于：{{newsDetail.updateTime}}
          </span>
        </p>
        <div class="news-d-content" v-html="newsDetail.content">
        </div>
      </div>
    </main>
    <BackTop></BackTop>
    <Footer></Footer>
  </div>
</template>
<script setup lang="ts">

import {ArrowRight} from "@element-plus/icons-vue";
import Header from "@/components/header/Header.vue";
import Footer from "@/components/header/Footer.vue";
import {useRouter} from "vue-router";
import BackTop from "@/components/BackTop.vue";
import {onMounted,ref} from "vue";
import {news} from "@/api/news.ts";

const router = useRouter()
const activeName = router.currentRoute.value.path

const newsId = ref(-1)
const newsDetail = ref({
  id: undefined,
  title: undefined,
  content: "",
  pic: undefined,
})
onMounted(()=>{
  newsId.value = router.currentRoute.value.query.nid
  news({id: newsId.value}).then((resp)=>{
    newsDetail.value = resp.data
  })
})
</script>
<style scoped>
.main {
  width: 80%;
  position: relative;
  top: 20px;
  margin: auto;
  border-top: 1px solid #000000;
  background-color: #fbf8f8;
}
.news-d-container{
  color: #000;
  margin: 0 auto;
  min-height: 800px;
}
.news-d-title{
  text-align: center;
  font-size: 20px;
  font-weight: bold;
}
.news-d-info{
  font-size: 16px;
  color: #aeaaaa;
  line-height: 16px;
  text-align: center;
  margin-top: 10px;
}
.news-d-content{
  padding: 80px;
}
pre {
  white-space: pre-wrap;
  word-wrap: break-word;
}
</style>